<template>
    <div>
        <el-header>投标记录</el-header>
        <el-row>
           <br>
        </el-row>
        <el-row>
            <el-col :span="22" :offset="1">
                <el-row style="background-color: #E4E7ED;height: 40px;">
                    <el-col :span="3" style="margin-top: 5px;">
                        <span>&nbsp</span>
                        <span>&nbsp</span>
                        <i class="el-icon-search"
                            style="font-size: 20px;"></i>
                        <span style="font-size: 20px;">高级查询</span>
                    </el-col>
                    <el-col :span="1" :offset="17" style="font-size: 20px;">
                        <el-button icon="el-icon-search" type="success" @click="searchInvests">查询</el-button>
                    </el-col>
                    <el-col :span="1" :offset="1" style="font-size: 20px;">
                        <el-button icon="el-icon-refresh-right" type="success" @click="resetReceivables" plain>重置</el-button>
                    </el-col>
                </el-row>
                <el-row style="border: 1px solid gray;height: 80px;">
                    <el-col :span="4" :offset="1" style="margin-top: 20px;">
                        <el-input placeholder="用户名" v-model="search.uname" clearable></el-input>
                    </el-col>
                    <el-col :span="4" :offset="2" style="margin-top: 20px;">
                        <el-input placeholder="项目名称" v-model="search.pname" clearable></el-input>
                    </el-col>
                    <el-col :span="4" :offset="2" style="margin-top: 20px;">
                        <el-input placeholder="出借人名" v-model="search.name" clearable></el-input>
                    </el-col>
                    <el-col :span="4" :offset="2" style="margin-top: 20px;">
                        <el-input placeholder="待还总额" v-model="search.money" clearable></el-input>
                    </el-col>
                </el-row>
                <el-row style="background-color: #E4E7ED;height: 40px;margin-top: 40px;">
                    <el-col :span="3" style="margin-top: 8px;">
                        <i class="el-icon-document"
                            style="font-size: 20px;"></i>
                        <span>数据记录</span>
                    </el-col>
                    <el-col :span="1" :offset="18" style="font-size: 20px;">
                        <el-button icon="el-icon-document-copy" type="success">导出表格</el-button>
                    </el-col>
                </el-row>
                <el-row>
                    <el-table :data="invests" style="width: 100%" >
                        <el-table-column prop="id" label="编号" align="center" width="60">
                        </el-table-column>
                        <el-table-column prop="uname" label="用户名" align="center" width="100">
                        </el-table-column>
                        <el-table-column prop="name" label="出借人姓名" align="center" width="100">
                        </el-table-column>
                        <el-table-column prop="pname" label="项目名称" align="center" width="80">
                        </el-table-column>
                        <el-table-column prop="type" label="项目类型" align="center" width="80">
                        </el-table-column>
                        <el-table-column prop="lmoney" label="出借金额" align="center" width="80">
                        </el-table-column>
                        <el-table-column prop="tmoney" label="实际金额" align="center" width="80">
                        </el-table-column>
                        <el-table-column prop="rmoney" label="使用红包金额" align="center" width="120">
                        </el-table-column>
                        <el-table-column prop="interest" label="利息" align="center" width="80">
                        </el-table-column>
                        <el-table-column prop="rinterest" label="加息" align="center" width="80">
                        </el-table-column>
                        <el-table-column prop="smoney" label="待收金额" align="center" width="100">
                        </el-table-column>
                        <el-table-column prop="ltime" value-format="yyyy-MM-dd HH:mm:ss" label="出借时间" align="center"
                            width="160">
                        </el-table-column>
                    </el-table>
                </el-row>
                <el-row>
                    <div style="text-align: center">
                        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                            :current-page="page" :page-sizes="[5, 10]" :page-size="size"
                            layout="total, sizes, prev, pager, next, jumper" :total="total">
                        </el-pagination>
                    </div>
                </el-row>

            </el-col>
        </el-row>
    </div>
</template>
<script>
export default{
    data(){
        return {
            search:{
                uname:"",
                pname:"",
                name:"",
                money:"",
                page: 1,
                size: 5,
            },
            page: 1,
            size: 5,
            total: 0,
            totalPage: 0,
            invests:[],
        }
    },methods:{
        searchInvests(){
            this.$axios.post("/receivables/searchInvests",this.search).then(res => {
                if(res.data.code == 200){
                    console.log(res.data.data.data);
                    this.invests = res.data.data.data;
                    this.total = res.data.data.total;
                    this.totalPage = res.data.data.totalPage;
                }
            })
        },
        resetReceivables(){
            this.search={
                uname:"",
                pname:"",
                name:"",
                money:"",
                page: 1,
                size: 5,
            }
        },
        handleSizeChange(val) {
            this.search.size = val;
            this.searchInvests()
        },
        handleCurrentChange(val) {
            this.search.page = val;
            this.searchInvests()
        },
    },mounted(){
        this.searchInvests()
    }
}
</script>
<style scoped>
.el-header {
    background-color: #67C23A;
    color: #333;
    text-align: center;
    line-height: 60px;
  }
</style>